<?php
/**
*
*	页头程序 @zairwolf
*
*/

if(!defined('IN')) {
	exit('Access Denied (header.inc.php)');
}

//设定在所有模板中自动被替换的变量集

global $Global, $_SYSTEM;

$_assign = array(
	'F_uid' => $_G['user_id'],
	'F_username' => $_G['user_name'],
	'G_sitename' => $_SYSTEM['SYSTEM']['SITE_NAME'],
	'G_siteurl' => $_SYSTEM['SYSTEM']['SITE_ADDR'],
);

//页头输出
function _header($seokeyword, $c='0',$type=0){
	global $_SYSTEM, $_CACHE;

	//二次输出检查
	if(defined('HEADER_SENDED')) {
		return;
	}else {
		define('HEADER_SENDED', true);
	}
	if(!is_array($seokeyword)){
		$seokeyword=array($seokeyword);
	}
	$seokeyword[] = $_SYSTEM['SYSTEM']['SITE_NAME'];
	$tpl = new T('header');
	$tpl->assign(array(
		'G_style'		=> STYLE,
		'G_bbsurl'		=> $_SYSTEM['SYSTEM']['BBS_URL'],
		'title'			=> implode(' - ', $seokeyword).(empty($_SYSTEM['SEO']['title']) ? '' : ' | '.$_SYSTEM['SEO']['title']),
		'keywords'		=> implode(', ', $seokeyword).(empty($_SYSTEM['SEO']['keywords']) ? '' : ', '.$_SYSTEM['SEO']['keywords']),
		'description'	=> empty($_SYSTEM['SEO']['description']) ? '' : $_SYSTEM['SEO']['description'],
		'novel_cats'	=> array_slice($_CACHE['subject'], 0, 14),
		'C_c'			=> $c,
	));
	if($type==0) $tpl->output();
	else return $tpl->output(1);
}

//页尾输出
function _footer(){
	global $_SYSTEM, $starttime;

	$tpl = new T('footer');
	$mtime = explode(' ', microtime());
	$totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);

	$tpl->assign(array(
		'G_bbsurl'     => $_SYSTEM['SYSTEM']['BBS_URL'],
		'G_miibeian'   => $_SYSTEM['SYSTEM']['miibeian'],
		'G_statcode'   => $_SYSTEM['DISPLAY']['statcode'],
		'G_SpeedTrace' => $_SYSTEM['DISPLAY']['speedtrace'],
		'C_totaltime'  => $totaltime,
		'C_dbcount'    => 1,//之后需要再加 zairwolf
	));
	$tpl->output();

	ob_end_flush();
	exit();
}

